/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.app.user.web;


import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.hibernate.validator.constraints.Length;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.jeesite.common.codec.DesUtils;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.idgen.IdGen;
import com.jeesite.common.mapper.JsonMapper;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.app.user.entity.AppUser;
import com.jeesite.modules.app.user.service.AppUserService;
import com.jeesite.modules.app.util.wx.WxUtils;
//import com.jeesite.modules.app.valid.service.TvalidCodeService;
import com.jeesite.modules.conf.AppController;
import com.jeesite.modules.conf.MessageCode;
import com.jeesite.modules.conf.RedisUtils;
import com.jeesite.modules.sys.entity.Employee;
import com.jeesite.modules.sys.entity.Office;
import com.jeesite.modules.sys.service.EmployeeService;
import com.jeesite.modules.sys.service.OfficeService;
//import com.jeesite.modules.sys.service.UserService;
import com.jeesite.modules.zx.customer.credit.details.entity.TcustomerCreditDetails;
import com.jeesite.modules.zx.customer.credit.details.service.TcustomerCreditDetailsService;
import com.jeesite.modules.zx.customer.points.details.entity.TcustomerPointsDetails;
import com.jeesite.modules.zx.customer.points.details.service.TcustomerPointsDetailsService;
import com.jeesite.modules.zx.sys.msg.push.entity.ZxMsgPush;
import com.jeesite.modules.zx.sys.msg.push.service.ZxMsgPushService;

/**
 * 用户表Controller
 * @author zpp
 * @version 2020-01-23
 */
@Controller
@RequestMapping(value = "/app/user/")
public class AppUserController {
	private static final Logger logger=LoggerFactory.getLogger(AppUserController.class);
	@Autowired
	private AppUserService appUserService;
//	@Autowired
//	private TvalidCodeService tvalidCodeService;
	@Autowired
	private EmployeeService employeeService;
	@Autowired
	private OfficeService officeService;
//	@Autowired
//	private UserService userService;
	@Autowired
	private TcustomerPointsDetailsService tcustomerPointsDetailsService;
	@Autowired
	private TcustomerCreditDetailsService tcustomerCreditDetailsService;
	@Autowired
   	private ZxMsgPushService zxMsgPushService;
	@Autowired
	private RedisUtils redisUtils;
	@RequestMapping(value="userInfo")
	public void userInfo(HttpServletRequest request,HttpServletResponse response){
		String userId=request.getParameter("userId");
		if(StringUtils.isBlank(userId)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "用户标识");
			return;
		}
		AppUser appUser = appUserService.get(userId);
		appUser.setPassword(null);
        JSONObject parseObject = JSONObject.parseObject(JsonMapper.toJson(appUser));
        AppController.renderSuccessObject(response, parseObject, MessageCode.SUCCESS_ACK);
	}
	/**
	 * 登录
	 */
	@RequestMapping(value="login",method=RequestMethod.POST)
	public void login(HttpServletRequest request,HttpServletResponse response){
		String mobile=request.getParameter("mobile");
		if(StringUtils.isEmpty(mobile)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "：手机号");
			return;
		}
		
		String password=request.getParameter("password");
		if(StringUtils.isEmpty(password)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "：密码");
			return;
		}
		String openid=request.getParameter("openid");
		if(StringUtils.isEmpty(openid)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "：openid");
			return;
		}
		String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
		//加密
		String encode=DesUtils.encode(password, secretKey);
		AppUser user=new AppUser();
		user.setMobile(mobile);
		user.setPassword(encode);
		List<AppUser> findList = appUserService.findList(user);
		if(findList!=null){
			if(findList.size()==1){
				AppUser entity = findList.get(0);
				//这个判断不能用，如果用户有多个账号就不能登录了
//				if (!openid.equals(entity.getWxOpenid())){
//					AppController.renderErrorString(response, MessageCode.ERROR_MESSAGE, "该账号已在别处登录！");
//					return;
//				}
				String sessionKey=IdGen.randomBase62(30)+IdGen.randomBase62(4).toLowerCase();
				entity.setSessionKey(sessionKey);
				redisUtils.set(entity.getId(), sessionKey);
			    TcustomerCreditDetails tcd=new TcustomerCreditDetails();
	    		tcd.setCreateBy(entity.getId());
	    		List<TcustomerCreditDetails> tcdList = tcustomerCreditDetailsService.findList(tcd);
	    		if(tcdList!=null&&tcdList.size()>0){
	    		  tcd=tcdList.get(0);
	    		}
	    		
	    		TcustomerPointsDetails tpd=new TcustomerPointsDetails();
	    		tpd.setCreateBy(entity.getId());
	    		List<TcustomerPointsDetails> tpdList=tcustomerPointsDetailsService.findList(tpd);
	    		if(tpdList!=null&&tpdList.size()>0){
	    			tpd=tpdList.get(0);
	    		}
	    		
	    		
	    		Long credit = tcd.getCredit();
	    		Long points = tpd.getPoints();
	    		entity.setCredit(credit);
	    		entity.setPoints(points);
	    		
	    		ZxMsgPush msg=new ZxMsgPush();
	    		msg.setReceiveCode(entity.getId());
	    		msg.setReadStatus("0");
	    		Long findCount = zxMsgPushService.findCount(msg);
	    		if(findCount!=null){
	    		  entity.setSysteminfo(findCount.intValue());
	    		}
				String refCode = entity.getRefCode();
				Employee employee = employeeService.get(refCode);
				String officeName = employee.getOffice().getOfficeName();
				String userjson = JsonMapper.toJson(entity);
				JSONObject parseObject = JSONObject.parseObject(userjson);
				parseObject.put("officeName", officeName);
				AppController.renderSuccessObject(response, parseObject, MessageCode.SUCCESS_ACK);
				return;
			}else{
				AppController.renderErrorString(response, MessageCode.ERROR_MESSAGE, "用户名或密码错误");
				return;
			}
		}
		return;
	}
	/**
	 * 注册接口
	 * @param request
	 * @param response
	 */
	@RequestMapping(value="register")     
	public void register(AppUser entity,HttpServletRequest request,HttpServletResponse response){
		 String userName=entity.getUserName();		// 用户昵称
		 if(StringUtils.isBlank(userName)){
			 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"真实名称");
			 return;
		 }
		 String password=entity.getPassword();		// 登录密码
         if(StringUtils.isBlank(password)){
        	 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"密码");
			 return;
		 }
         String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
 		 String encode=DesUtils.encode(password, secretKey);
    	 entity.setPassword(encode);
		 String mobile=entity.getMobile();		// 手机号码
		 if(StringUtils.isBlank(mobile)){
    		 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "手机号");
    		 return;
    	 }else{
        	 AppUser user=new AppUser();
        	 user.setMobile(mobile);
        	 long findCount = appUserService.findCount(user);
        	 if(findCount>0){
        		 AppController.renderErrorString(response, MessageCode.PARAMETER_INVALLD, "手机号已存在");
        		 return;
        	 }
    	 }
		 String sex=entity.getSex();		// 用户性别
         if(StringUtils.isBlank(sex)){
        	 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"性别");
			 return;
		 }
//		 String avatar=entity.getAvatar();		// 头像路径
//         
//		 String sign=entity.getSign();		// 个性签名
         String appid=request.getParameter("appid");
         if(StringUtils.isBlank(appid)){
        	 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"appid");
			 return;
         }
         String secret=request.getParameter("secret");
         if(StringUtils.isBlank(secret)){
        	 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"secret");
			 return;
         }
         String js_code=request.getParameter("js_code");
         if(StringUtils.isBlank(js_code)){
        	 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"js_code");
			 return;
         }
		 JSONObject openJson=WxUtils.getOpenId(appid, secret, js_code);		// 绑定的微信号
		 logger.info("register()获取微信标识："+mobile+"=="+openJson.toJSONString());
		 String wxOpenid="";
		 if(openJson.containsKey("openid")){
			 wxOpenid=openJson.getString("openid"); 
		 }
		 String sessionKey=IdGen.randomBase62(30)+IdGen.randomBase62(4).toLowerCase();
		 entity.setSessionKey(sessionKey);
		 if(StringUtils.isNotBlank(wxOpenid)){
			 
    		 AppUser user=new AppUser();
    		 user.setWxOpenid(wxOpenid);    		 
    		 List<AppUser> findList = appUserService.findList(user);
    		 //直接取消掉注册的openid
        	 if(findList!=null&&findList.size()>0){
        		 for(AppUser old:findList){
        			 String ident=old.getIdentity();
        			 if(StringUtils.isNotBlank(ident)){
        				 if(ident.equals("visitor")){
        					 entity.setUserCode(old.getUserCode());
        					 entity.setId(old.getUserCode());
        					 entity.setWxOpenid(wxOpenid);
        					 break;
        				 }
        			 }
        			 entity.setWxOpenid(null);
        		 }
        	 }
    	 }else{
    		 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"参数获取失败，请联系管理员");
			 return;
    	 }
		 Integer accept=entity.getAccept();//是否同意条款
         if(accept==null){
        	 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"请阅读软件条款");
			 return;
		 }
//		 String introduce=entity.getIntroduce();
         String codeOffice="";
		 String headOffice=entity.getHeadOffice();
         if(StringUtils.isBlank(headOffice)){
        	 AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"请选择所属机构");
			 return;
		 }else{
			 codeOffice=headOffice;
		 }
		 String branchOffice=entity.getBranchOffice();
         if(StringUtils.isNotBlank(branchOffice)){
        	 codeOffice=branchOffice;
		 }
		 String subBranch=entity.getSubBranch();
         if(StringUtils.isNotBlank(subBranch)){
        	 codeOffice=subBranch;
		 }
		 String smallLocalBranch=entity.getSmallLocalBranch();
         if(StringUtils.isNotBlank(smallLocalBranch)){
        	 codeOffice=smallLocalBranch;
		 }
       //设置必填字段 用户类型
    	 entity.setUserType("employee");
    	 //设置必填字段管理员类型
    	 entity.setMgrType("0");
    	 entity.setCorpCode("0");
    	 entity.setCorpName("JeeSite");
    	 String empcode=IdGen.randomBase62(30)+IdGen.randomBase62(4).toLowerCase();
    	 entity.setRefCode(empcode);
    	 entity.setRefName(entity.getUserName());
    	 entity.setLoginCode(mobile);
    	 entity.setState(4);
    	 entity.setIdentity("visitor");
    	 if(StringUtils.isNotBlank(entity.getUserCode())){
    		 
    		 entity.setIsNewRecord(false);
    		 appUserService.update(entity);
    	 }else{
    		 entity.setIsNewRecord(true);
    		 appUserService.save(entity);
    	 }
    	 redisUtils.set(entity.getId(), sessionKey);
    	 try {
			    TcustomerCreditDetails tcd=new TcustomerCreditDetails();
	    		tcd.setCreateBy(entity.getId());
	    		List<TcustomerCreditDetails> tcdList = tcustomerCreditDetailsService.findList(tcd);
	    		if(tcdList!=null&&tcdList.size()>0){
	    		  tcd=tcdList.get(0);
	    		}
	    		
	    		TcustomerPointsDetails tpd=new TcustomerPointsDetails();
	    		tpd.setCreateBy(entity.getId());
	    		List<TcustomerPointsDetails> tpdList=tcustomerPointsDetailsService.findList(tpd);
	    		if(tpdList!=null&&tpdList.size()>0){
	    		  tpd=tpdList.get(0);
	    		}
	    		
	    		Long credit = tcd.getCredit();
	    		Long points = tpd.getPoints();
	    		entity.setCredit(credit==null?0:credit);
	    		entity.setPoints(points==null?0:points);
	    		
	    		ZxMsgPush msg=new ZxMsgPush();
	    		msg.setReceiveCode(entity.getId());
	    		msg.setReadStatus("0");
	    		Long findCount = zxMsgPushService.findCount(msg);
	    		if(findCount!=null){
	    		  entity.setSysteminfo(findCount.intValue());
	    		}
	    		//保存员工
				Employee emp=new Employee();
	     		emp.setEmpCode(empcode);
	     		emp.setEmpNo(entity.getUserName());
	     		emp.setEmpName(entity.getUserName());
	     		Office office=new Office();
	     		office.setOfficeCode(codeOffice);
	     		Office office2 = officeService.get(codeOffice);
	     		office.setOfficeName(office2.getOfficeName());
				emp.setOffice(office);
				emp.setIsNewRecord(true);
				emp.setCorpCode("0");
				emp.setCorpName("JeeSite");
				employeeService.save(emp);				
				String json = JsonMapper.toJson(entity);
	        	JSONObject parseObject = JSONObject.parseObject(json);
	        	parseObject.put("officeName",office2.getFullName());
	        	AppController.renderSuccessObject(response, parseObject, MessageCode.SUCCESS_ACK);
			} catch (Exception e) {
				AppController.renderSuccessObject(response, "", MessageCode.SYSTEM_DB_ERROR);
			}    
	}
	
	@RequestMapping(value="openiduser")
	public void openiduser(HttpServletRequest request,HttpServletResponse response){
		String appid=request.getParameter("appid");
		if(StringUtils.isBlank(appid)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"appId");
			return;
		}
		String secret=request.getParameter("secret");
		if(StringUtils.isBlank(secret)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"secret");
			return;
		}
		String js_code=request.getParameter("js_code");
		if(StringUtils.isBlank(js_code)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"js_code");
			return;
		}
		JSONObject openJson=WxUtils.getOpenId(appid, secret, js_code);		// 绑定的微信号
		 String openid="";
		 logger.info("openiduser()获取微信标识：=="+openJson.toJSONString());
		 if(openJson.containsKey("openid")){
			 openid=openJson.getString("openid"); 
		 }
		 String sessionKey=IdGen.randomBase62(30)+IdGen.randomBase62(4).toLowerCase();
		 if(StringUtils.isBlank(openid)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED,"网络异常");
		 	return;
		}
		   AppUser entity=new AppUser();
		   entity.setWxOpenid(openid);
		   List<AppUser> findList = appUserService.findList(entity);
		   if(findList!=null&&findList.size()>0){
			    entity=findList.get(0);
			    //更新登录状态
			    entity.setSessionKey(sessionKey);
			    redisUtils.set(entity.getId(), sessionKey);
//			    appUserService.update(entity);
			    TcustomerCreditDetails tcd=new TcustomerCreditDetails();
	    		tcd.setCreateBy(entity.getId());
	    		List<TcustomerCreditDetails> tcdList = tcustomerCreditDetailsService.findList(tcd);
	    		if(tcdList!=null&&tcdList.size()>0){
	    		  tcd=tcdList.get(0);
	    		}
	    		
	    		TcustomerPointsDetails tpd=new TcustomerPointsDetails();
	    		tpd.setCreateBy(entity.getId());
	    		List<TcustomerPointsDetails> tpdList=tcustomerPointsDetailsService.findList(tpd);
	    		if(tpdList!=null&&tpdList.size()>0){
	    			tpd=tpdList.get(0);	
	    		}
	    		
	    		
	    		Long credit = tcd.getCredit();
	    		Long points = tpd.getPoints();
	    		entity.setCredit(credit==null?0:credit);
	    		entity.setPoints(points==null?0:points);
	    		
	    		ZxMsgPush msg=new ZxMsgPush();
	    		msg.setReceiveCode(entity.getId());
	    		msg.setReadStatus("0");
	    		Long findCount = zxMsgPushService.findCount(msg);
	    		if(findCount!=null){
	    		  entity.setSysteminfo(findCount.intValue());
	    		}
	    		JSONObject json=JSONObject.parseObject(JsonMapper.toJson(entity));
				String refCode = entity.getRefCode();
				if(StringUtils.isNotBlank(refCode)){
					Employee employee = employeeService.get(refCode);
					if(employee!=null){
						Office office = employee.getOffice();
						if(office!=null){
						String officeName = office.getOfficeName();
						json.put("officeName", officeName);
						}
					}
				}
			   AppController.renderSuccessObject(response, json, MessageCode.SUCCESS_ACK);
			   return;
		   }else if(findList.size()==0){			   
				 entity.setUserName("游客");
				 String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
		 		 String encode=DesUtils.encode("123456", secretKey);
		    	 entity.setPassword(encode);
		    	 entity.setUserType("employee");
		    	 entity.setIdentity("visitor");
		    	 //设置必填字段管理员类型
		    	 entity.setMgrType("0");
		    	 entity.setCorpCode("0");
		    	 entity.setCorpName("JeeSite");
		    	 appUserService.save(entity);
		    	 redisUtils.set(entity.getId(), sessionKey);
		    	 entity.setSysteminfo(0);
		    	 entity.setCredit(0L);
		    	 entity.setPoints(0L);
		    	 JSONObject json=JSONObject.parseObject(JsonMapper.toJson(entity));
		    	 AppController.renderSuccessObject(response, json,MessageCode.SUCCESS_ACK);
			}
	}
	
	/**
	 * 更新用户信息
	 * @param entity
	 * @param request
	 * @param response
	 */
	@RequestMapping(value="updateUserInfo")
	public void updateUserInfo(AppUser entity,HttpServletRequest request,HttpServletResponse response){
		String id = entity.getId();
		if(StringUtils.isBlank(id)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "操作标识");
			return;
		}
		String userId=request.getParameter("userId");
		if(StringUtils.isNotBlank(userId)){
			entity.setUpdateBy(userId);
		}
		String oldpassword = entity.getOldpassword();
		if(StringUtils.isNotBlank(oldpassword)){
			AppUser selUser=new AppUser();
			selUser.setUserCode(entity.getUserCode());
			String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
			String encode=DesUtils.encode(oldpassword, secretKey);
			selUser.setPassword(encode);
			long findCount = appUserService.findCount(selUser);
			if(findCount==0l){
				AppController.renderErrorString(response, MessageCode.ERROR_MESSAGE, "旧密码错误");
				return;
			}
		}
		String newpassword = entity.getNewpassword();
		if(StringUtils.isNotBlank(newpassword)){
			if(StringUtils.isBlank(oldpassword)){
				AppController.renderErrorString(response, MessageCode.ERROR_MESSAGE, "请输入旧密码");
				return;
			}
			if(oldpassword.equals(newpassword)){
				AppController.renderErrorString(response, MessageCode.ERROR_MESSAGE, "新密码不能和旧密码相同");
				return;
			}
			String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
			String encode=DesUtils.encode(newpassword, secretKey);
			entity.setPassword(encode);
		}
		appUserService.update(entity);
		JSONObject obj=JSONObject.parseObject(JsonMapper.toJson(entity));
		AppController.renderSuccessObject(response, obj, MessageCode.SUCCESS_ACK);
	}
	@RequestMapping(value="selectPassword")
	public void selectPassword(HttpServletRequest request,HttpServletResponse response){
		AppUser entity=new AppUser();
		String mobile=request.getParameter("mobile");
		if(StringUtils.isBlank(mobile)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "手机号");
			return;
		}
		entity.setMobile(mobile);
		String pwdQuestion=request.getParameter("pwdQuestion");
		if(StringUtils.isNotBlank(pwdQuestion)){
			entity.setPwdQuestion(pwdQuestion);
			String pwdQuestionAnswer=request.getParameter("pwdQuestionAnswer");
			if(StringUtils.isBlank(pwdQuestionAnswer)){
				AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "问题1答案");
				return;
			}else{
				entity.setPwdQuestionAnswer(pwdQuestionAnswer);
			}
			
		}
		String pwdQuestion2=request.getParameter("pwdQuestion2");
		if(StringUtils.isNotBlank(pwdQuestion2)){
			entity.setPwdQuestion2(pwdQuestion2);
			String pwdQuestionAnswer2=request.getParameter("pwdQuestionAnswer2");
			if(StringUtils.isBlank(pwdQuestionAnswer2)){
				AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "问题2答案");
				return;
			}else{
				entity.setPwdQuestionAnswer2(pwdQuestionAnswer2);
			}
		}
		List<String> list=new ArrayList<String>();
	    list.add("0");
	    list.add("4");
	    list.add("5");
	    entity.getSqlMap().getWhere().disableAutoAddStatusWhere().and("status", QueryType.IN, list);
		List<AppUser> findList = appUserService.findList(entity);
		if(findList!=null&&findList.size()>0){
			AppUser appUser = findList.get(0);
			String password = appUser.getPassword();
			String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
 		    String encode=DesUtils.decode(password, secretKey);
    	    JSONObject json=new JSONObject();
    	    json.put("password", encode);
    	    AppController.renderSuccessObject(response, json, MessageCode.SUCCESS_ACK);
		}else{
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "密保问题错误");
		}		
	}
	@RequestMapping(value="selectQuetions")
	public void selectQuetions(HttpServletRequest request,HttpServletResponse response){
		String mobile=request.getParameter("mobile");
		if(StringUtils.isBlank(mobile)){
			AppController.renderErrorString(response, MessageCode.PARAMETER_IS_NEED, "手机号");
			return;
		}
		AppUser entity=new AppUser();
		entity.setMobile(mobile);
		List<String> list=new ArrayList<String>();
	    list.add("0");
	    list.add("4");
	    list.add("5");
	    entity.getSqlMap().getWhere().disableAutoAddStatusWhere().and("status", QueryType.IN, list);
	    List<AppUser> findList = appUserService.findList(entity);
	    JSONObject json=new JSONObject();
	    for(AppUser mod:findList){
			String pwdQuestion = mod.getPwdQuestion();
			if(StringUtils.isNotBlank(pwdQuestion)){
				json.put("pwdQuestion", pwdQuestion);
			}
			String pwdQuestion2=mod.getPwdQuestion2();
			if(StringUtils.isNotBlank(pwdQuestion2)){
				json.put("pwdQuestion2", pwdQuestion2);
			}
	    }
	    if(json.size()>0){
	      AppController.renderSuccessObject(response, json, MessageCode.SUCCESS_ACK);
	      return;
	    }else{
	    	AppController.renderErrorString(response, MessageCode.ERROR_MESSAGE, "该手机号没有设置密保问题");
	    	return;
	    }
	    
	}
}